package com.hzhr.iot.cqgas.ds.controller;

import com.hzhr.iot.cqgas.ds.dao.user.example.UsrCompanyDao;
import com.hzhr.iot.cqgas.ds.entity.user.UsrCompanyEntity;
import com.hzhr.iot.cqgas.ds.entity.user.UsrCompanyExample;
import com.hzhr.iot.cqgas.ds.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CompanyController {
    @Autowired
    CompanyService companyService;
    @Autowired
    UsrCompanyDao usrCompanyDao;

    @RequestMapping(value = "/syncIotCompany")
    public void syncIotCompany() {
        UsrCompanyEntity usrCompanyEntity = new UsrCompanyEntity();
        usrCompanyEntity.setState("3");
        UsrCompanyExample usrCompanyExample = new UsrCompanyExample();
        usrCompanyExample.createCriteria().andOutIdIsNotNull();
        usrCompanyDao.updateByExampleSelective(usrCompanyEntity, usrCompanyExample);

        companyService.syncIotCompany();

        usrCompanyExample = new UsrCompanyExample();
        usrCompanyExample.createCriteria().andStateEqualTo("3");
        usrCompanyDao.deleteByExample(usrCompanyExample);
    }
}
